<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml"
     	xmlns:h="http://java.sun.com/jsf/html"
     	xmlns:f="http://java.sun.com/jsf/core"
     	xmlns:ui="http://java.sun.com/jsf/facelets" 
     	xmlns:p="http://primefaces.org/ui" 
		template="/WEB-INF/templates/imo_mini_page_template.xhtml">

	<ui:define name="titulo_secao">Portifólio de Vagas</ui:define>
	
	<ui:define name="conteudo_secao">
	
		<h:panelGroup id="panel_busca_vagas" rendered="#{vagaBean.exibirBuscaVagas}">
		
			<div class="contact_form">
		
				<h:form id="form_portifolio">
					
					<p:outputLabel value="Cargo" for="select_cargo_portifolio"/>
					<p:selectOneMenu id="select_cargo_portifolio" value="#{vagaBean.codigoCargoConsulta}">
						<f:selectItem itemLabel="Selecione o cargo" itemValue="#{null}"/>
						<f:selectItems value="#{vagaBean.listaSelectCargos}"/>
					</p:selectOneMenu>
					<div class="margin_bottom_10"/>
					
					<p:outputLabel value="Escolaridade" for="escolaridade_busca"/>
					<p:selectOneMenu id="escolaridade_busca" value="#{vagaBean.codigoEscolaridadeConsulta}" 
						required="true" requiredMessage="Campo Escolaridade obrigatório">
						<f:selectItem itemLabel="Selecione a escolaridade" itemValue="#{null}"/>
						<f:selectItems value="#{vagaBean.listaSelectEscolaridade}"/>
					</p:selectOneMenu>
					<div class="margin_bottom_10"></div>
					
					<p:commandButton actionListener="#{vagaBean.buscarVagas}" ajax="false" value="Buscar" update="form_portifolio"/>
					
					<p:messages/>
					
				</h:form>
				
			</div>
			
			<div class="margin_bottom_10"></div>
			
			<h:dataTable value="#{vagaBean.vagasEncontradas}" var="vaga" styleClass="vaga"
				cellspacing="0" cellpadding="0" border="0" rowClasses="odd,even"
				rendered="#{vagaBean.exibirVagasDisponiveis}">
			
				<h:column>
					<f:facet name="header">ID</f:facet>
					<h:outputText value="#{vaga.codigo}"></h:outputText>
				</h:column>
				
				<h:column>
					<f:facet name="header">Cargo</f:facet>
					<h:outputText value="#{vaga.cargo.nome}"></h:outputText>
				</h:column>
				
				<h:column>
					<f:facet name="header">#Vagas</f:facet>
					<h:outputText value="#{vaga.numeroPostos}"></h:outputText>
				</h:column>
				
				<h:column>
					<f:facet name="header">Detalhes</f:facet>
					<h:form>
						<h:commandLink action="#{vagaBean.buscarVaga}" value="Detalhes">
							<f:setPropertyActionListener target="#{vagaBean.codigoVagaProcurada}" value="#{vaga.codigo}"/>
						</h:commandLink>
					</h:form>
				</h:column>
				
			</h:dataTable>
		
		</h:panelGroup>
		
		<h:panelGroup id="panel_candidatura" rendered="#{vagaBean.exibirDetalhesVaga}">
		
			<div class="contact_form">
			
				<h:form id="form_candidatura">
					
					<h:inputHidden value="#{vagaBean.vagaRecuperada.codigo}" />
					
					<p:outputLabel value="Cargo" />
					<p:inputText styleClass="input_field" value="#{vagaBean.vagaRecuperada.cargo.nome}" disabled="true" />
					<div class="margin_bottom_10"></div>
					
					<p:outputLabel value="Escolaridade" />
					<p:inputText styleClass="input_field" value="#{vagaBean.vagaRecuperada.escolaridade.descricao}" disabled="true" />
					<div class="margin_bottom_10"></div>
					
					<p:outputLabel value="Num. Postos" />
					<p:inputText styleClass="input_field" value="#{vagaBean.vagaRecuperada.numeroPostos}" disabled="true" />
					<div class="margin_bottom_10"></div>
					
					<p:outputLabel value="Experiência" />
					<p:inputText styleClass="input_field" value="#{vagaBean.vagaRecuperada.mesesExperiencia} meses" disabled="true" />
					<div class="margin_bottom_10"></div>
					
					<p:outputLabel value="Usuário" for="user_trab"/>
					<p:inputText id="user_trab" value="#{vagaBean.usuarioTrabalhador}" 
						maxlength="8" styleClass="input_field" required="true" requiredMessage="Campo Usuário obrigatório"/>
					<div class="margin_bottom_10"></div>
					
					<p:outputLabel value="Senha" for="senha_trab"/>
					<p:password id="senha_trab" value="#{vagaBean.senhaTrabalhador}" maxlength="6" styleClass="input_field"
						validator="#{trabalhadorBean.validarUsuarioSenha}" required="true" requiredMessage="Campo Senha obrigatório"
						style="width: 60px;"/>
					<div class="margin_bottom_10"></div>
					
					<p:commandButton actionListener="#{vagaBean.registrarCandidatura}" ajax="false" value="Candidatar" update="form_candidatura" />
					<p:commandButton actionListener="#{vagaBean.cancelarCandidatura}" ajax="false" value="Cancelar" immediate="true" />
					
					<p:messages/>
				
				</h:form>
					
			</div>
		
		</h:panelGroup>

	</ui:define>
	
</ui:composition>